000100******************************************************************
000200*PROGRAM : Inquiry a registration of a studen
000300*AUTHOR  : Minh-Tuan Ta
000400******************************************************************
000500 IDENTIFICATION DIVISION.
000600 PROGRAM-ID. REG-I.
000700 ENVIRONMENT DIVISION.
000800     SELECT IOFILE       ASSIGN TO "REGMST.DAT"
000900                         ORGANIZATION    IS INDEXED
001000                         ACCESS          IS DYNAMIC
001100                         RECORD KEY      IS IO-REG-ID
001200                         FILE STATUS     IS WS-STAT.
001300
001400     SELECT INSCHED      ASSIGN TO "SCHEDMST.DAT"
001500                         ORGANIZATION    IS INDEXED
001600                         ACCESS          IS DYNAMIC
001700                         RECORD KEY      IS SCHED-ID
001800                         FILE STATUS     IS WS-STAT.
001900
002000     SELECT INSTU        ASSIGN TO "STUMST.DAT"
002100                         ORGANIZATION    IS INDEXED
002200                         ACCESS          IS DYNAMIC
002300                         RECORD KEY      IS STU-ID
002400                         ALTERNATE KEY   IS STU-LNAME
002500                                         WITH DUPLICATES
002600                         FILE STATUS     IS WS-STAT.
002700
002800     SELECT INCRS        ASSIGN TO "CRSMST.DAT"
002900                         ORGANIZATION    IS INDEXED
003000                         ACCESS          IS DYNAMIC
003100                         RECORD KEY      IS CRS-ID
003200                         FILE STATUS     IS WS-STAT.
003300
003400     SELECT ININST       ASSIGN TO "INSTMST.DAT"
003500                         ORGANIZATION    IS INDEXED
003600                         ACCESS          IS DYNAMIC
001100                         RECORD KEY    IS INST-ID
                               ALTERNATE KEY IS INST-NAME
                                             WITH DUPLICATES
001200                         FILE STATUS   IS WS-STAT.
003900
004000     SELECT INBLDG       ASSIGN TO "BLDGMST.DAT"
004100                         ORGANIZATION    IS INDEXED
004200                         ACCESS          IS DYNAMIC
004300                         RECORD KEY      IS BLDG-ID
004400                         FILE STATUS     IS WS-STAT.
004500
004600 DATA DIVISION.
004700 FILE SECTION.
004800 FD  IOFILE.
004900 01  IO-REC.
005000     05 IO-REG-ID.
005100         10 IO-TERM     PIC X(6).
005200         10 IO-CRN      PIC 9(4).
005300         10 IO-STU-ID   PIC 9(4).
005400     05  IO-ACTIVE      PIC X.
005500
005600 FD  INSCHED.
005700 01  SCHED-REC.
005800     05  SCHED-ID.
005900         10  SCHED-TERM     PIC X(6).
006000         10  SCHED-CRN      PIC 9(4).
006100     05  SCHED-CRS-ID       PIC X(8).
006200     05  SCHED-BLDG-CODE    PIC X(11).
006300     05  SCHED-INST-ID      PIC 9(3).
006400     05  SCHED-TIME         PIC X(15).
006500     05  SCHED-ACTIVE       PIC X.
006600
006700 FD  INSTU.
006800 01  STU-REC.
006900     05  STU-ID              PIC 9(4).
007000     05  STU-FNAME           PIC X(20).
007100     05  STU-LNAME           PIC X(20).
007200     05  STU-STREET          PIC X(30).
007300     05  STU-ZIP             PIC X(5).
007400     05  STU-ACTIVE          PIC X.
007500
007600 FD  INCRS.
007700 01  CRS-REC.
007800     05  CRS-ID              PIC X(8).
007900     05  CRS-NAME            PIC X(34).
008000     05  CRS-HR              PIC 99.
008100     05  CRS-ACTIVE          PIC X.
008200
008300 FD  ININST.
008400 01  INST-REC.
008500     05  INST-ID             PIC 9(3).
008600     05  INST-NAME           PIC X(20).
008700     05  INST-ACTIVE         PIC X.
008800
008900 FD  INBLDG.
009000 01  BLDG-REC.
009100     05  BLDG-ID             PIC X(11).
009200     05  BLDG-CAPACITY       PIC 9(3).
009300     05  BLDG-ACTIVE         PIC X.
009400
009500 WORKING-STORAGE SECTION.
009600 01  WS-STAT             PIC XX.
009700 01  WS-EOF              PIC X VALUE 'N'.
009800 01  WS-REGKEY.
009900     05  WS-TERM             PIC 9(6).
010000     05  WS-CRN              PIC 9(4).
010100     05  WS-STU-ID           PIC 9(4).
010200 01  WS-ACTIVE           PIC X.
010300 01  WS-DATE.
010400     03  WS-YEAR         PIC 99.
010500     03  WS-MONTH        PIC 99.
010600     03  WS-DAY          PIC 99.
010700 01  WS-ERR              PIC X VALUE 'N'.
010800 01  WS-CONT             PIC X VALUE 'Y'.
010900
011000 SCREEN SECTION.
011100 01  INPUT-SCRN.
011200         05  BLANK SCREEN.
011300         05  LINE 1  COL 01  VALUE "REGISTRATION INQUIRY".
011400         05          COL 73  PIC 9(2) FROM WS-MONTH.
011500         05          COL 75  VALUE "/".
011600         05          COL 76  PIC 9(2) FROM WS-DAY.
011700         05          COL 78  VALUE "/".
011800         05          COL 79  PIC 9(2) FROM WS-YEAR.
011900         05  LINE 2  COL 37  VALUE "REGISTRATION INQUIRY".
012000         05  INPUT-TERM-SCRN.
012100             10  LINE 4  COL 20  VALUE "TERM".
012200             10          COL 40  PIC X(6) TO IO-TERM.
012300             10          COL 40  PIC X(6) FROM IO-TERM.
012400         05  INPUT-CRN-SCRN.
012500             10  LINE 5  COL 20  VALUE "CRN".
012600             10          COL 40  PIC 9(4) TO IO-CRN.
012700             10          COL 40  PIC 9(4) FROM IO-CRN.
012800         05  INPUT-STU-ID-SCRN.
012900             10  LINE 6 COL 20  VALUE "STUDENT ID".
013000             10          COL 40  PIC 9(4) TO IO-STU-ID.
013100             10          COL 40  PIC 9(4) FROM IO-STU-ID.
013200         05  LINE 7  COL 25  VALUE "COURSE ID".
013300         05          COL 40  PIC X(8) FROM SCHED-CRS-ID.
013400         05  LINE 8  COL 25  VALUE "COURSE NAME".
013500         05          COL 40  PIC X(34) FROM CRS-NAME.
013600         05  LINE 9  COL 25  VALUE "CREDIT HR".
013700         05          COL 40  PIC 99  FROM CRS-HR.
013800         05  LINE 10  COL 25  VALUE "BUILDING".
013900         05          COL 40  PIC X(10) FROM SCHED-BLDG-CODE.
014000         05  LINE 11 COL 25  VALUE "CAPACITY".
014100         05          COL 40  PIC 9(3) FROM BLDG-CAPACITY.
014200         05  LINE 12 COL 25  VALUE "INSTRUCTOR".
014300         05          COL 40  PIC X(20) FROM INST-NAME.
014400         05  LINE 13 COL 25  VALUE "TIME".
014500         05          COL 40  PIC X(15) FROM SCHED-TIME.
014600         05  LINE 14 COL 20  VALUE "ACTIVE(Y/N)?".
014700         05          COL 40  PIC X FROM IO-ACTIVE.
014800         05  INPUT-CONT-SCRN.
014900             10  LINE 15 COL 20  VALUE "CONTINUE (Y/N)?".
015000             10          COL 40  PIC X TO WS-CONT AUTO.
015100
015200         05  LINE 17 COL 34  VALUE "(ENTER XXX TO TERM TO EXIT)".
015300
015400 01  ERROR-SCRN.
015500     03  BLANK SCREEN.
015600     03  LINE 12 COL 32 VALUE "CAN NOT FIND THE REGISTRATION".
015700     03  LINE 14 COL 32 VALUE "FILE STATUS:".
015800     03          COL 46 PIC XX FROM WS-STAT.
015900     03  LINE 16 COL 32 VALUE "CONTINUE(Y/N)?".
016000     03          COL 47 PIC X TO WS-CONT AUTO.
016100
016200
016300 PROCEDURE DIVISION.
016400 100-MAIN.
016500     ACCEPT WS-DATE FROM DATE
016600     OPEN    I-O IOFILE
016700             INPUT INSCHED
016800             INPUT INSTU
016900             INPUT ININST
017000             INPUT INCRS
017100             INPUT INBLDG
017200
017300     MOVE SPACES TO IO-TERM
017400     MOVE ZEROS TO IO-CRN
017500     MOVE SPACES TO SCHED-CRS-ID
017600     MOVE SPACES TO CRS-NAME
017700     MOVE ZEROS TO CRS-HR
017800     MOVE SPACES TO SCHED-BLDG-CODE
017900     MOVE ZEROS TO BLDG-CAPACITY
018000     MOVE SPACES TO INST-NAME
018100     MOVE SPACES TO SCHED-TIME
018200     MOVE ZEROS TO IO-STU-ID
018300     MOVE SPACES TO IO-ACTIVE
           MOVE SPACES TO WS-CONT
018400
018500     DISPLAY INPUT-SCRN
018600     ACCEPT INPUT-TERM-SCRN
018700
018800     PERFORM UNTIL IO-TERM = 'XXX' OR WS-CONT = 'N'
018900
019000         ACCEPT INPUT-CRN-SCRN
019100         ACCEPT INPUT-STU-ID-SCRN
019200
019300         MOVE 'N' TO WS-ERR
019400
019500         START IOFILE KEY = IO-REG-ID
019600             INVALID KEY MOVE 'Y' TO WS-ERR
019700         END-START
019800
019900         IF NOT WS-ERR = 'Y'
020000             READ IOFILE NEXT RECORD
020100             END-READ
020200
020300             MOVE IO-TERM TO SCHED-TERM
020400             MOVE IO-CRN TO SCHED-CRN
020500
020600             START INSCHED KEY = SCHED-ID
020700             END-START
020800
020900             READ INSCHED NEXT RECORD
021000             END-READ
021100
021200             MOVE IO-STU-ID TO STU-ID
021300
021400             START INSTU KEY = STU-ID
021500             END-START
021600
021700             READ INSTU NEXT RECORD
021800             END-READ
021900
022000             MOVE SCHED-BLDG-CODE TO BLDG-ID
022100             MOVE SCHED-CRS-ID TO CRS-ID
022200             MOVE SCHED-INST-ID TO INST-ID
022300
022400             START INBLDG KEY = BLDG-ID
022500             END-START
022600
022700             READ INBLDG NEXT RECORD
022800             END-READ
022900
023000             START ININST KEY = INST-ID
023100             END-START
023200
023300             READ ININST NEXT RECORD
023400             END-READ
023500
023600             START INCRS KEY = CRS-ID
023700             END-START
023800
023900             READ INCRS NEXT RECORD
024000             END-READ
024100
024200             DISPLAY INPUT-SCRN
024300             ACCEPT INPUT-CONT-SCRN
024400
024500         ELSE
024600             DISPLAY ERROR-SCRN
024700             ACCEPT ERROR-SCRN
024800         END-IF
024900
025000         IF NOT WS-CONT = 'N'
025100             MOVE SPACES TO IO-TERM
025200             MOVE ZEROS TO IO-CRN
025300             MOVE SPACES TO SCHED-CRS-ID
025400             MOVE SPACES TO CRS-NAME
025500             MOVE ZEROS TO CRS-HR
025600             MOVE SPACES TO SCHED-BLDG-CODE
025700             MOVE ZEROS TO BLDG-CAPACITY
025800             MOVE SPACES TO INST-NAME
025900             MOVE SPACES TO SCHED-TIME
026000             MOVE ZEROS TO IO-STU-ID
026100             MOVE SPACES TO IO-ACTIVE
026200
026300             DISPLAY INPUT-SCRN
026400             ACCEPT INPUT-TERM-SCRN
026500         END-IF
026600
026700     END-PERFORM
026800
026900     CLOSE IOFILE
027000     CLOSE INSCHED
027100     CLOSE INSTU
027200     CLOSE ININST
027300     CLOSE INCRS
027400     CLOSE INBLDG
027500
027600     EXIT PROGRAM.
027700
027800
